import cv2

vc = cv2.VideoCapture(0)

while True:
    ret, frame = vc.read()
    if not ret:
        print('error')
        break
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    frame = cv2.Canny(frame, 3, 9, 3)

    cv2.imshow('edge detect', frame)
    if cv2.waitKey(30) != -1:
        break